/*
 * JDialogSeleccionPropiedadesClase.java
 *
 * Copyright 2011 Universidad Francisco de Paula Santander (UFPS).
 * Todos los Derechos Reservados.
 * Created on 2/03/2011, 11:49:39 PM
 */

package com.ufps.cuatro.vistas.representacion;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.JComboBox;
import javax.swing.JList;
import javax.swing.ListSelectionModel;

import org.jdesktop.application.Action;

import com.ufps.cuatro.CuatroApp;
import com.ufps.cuatro.controlador.listener.ControllerListenerPopupJTree;
import com.ufps.cuatro.controlador.render.UtilRender;
import com.ufps.cuatro.modelo.analizador.ObjetoReflexion;
import com.ufps.cuatro.modelo.representacion.ObjetoTipoDatoReflexion;
import com.ufps.cuatro.modelo.representacion.UtilRepresentacion;
import com.ufps.cuatro.util.Bandera;
import com.ufps.cuatro.util.ImplementarAyudaStandar;
import com.ufps.cuatro.util.MessageWindow;
import com.ufps.cuatro.util.TipoCaso;
import com.ufps.cuatro.util.Utileria;
import com.ufps.cuatro.util.model.MyCheckItemPropertiesClass;
import com.ufps.cuatro.util.render.CheckListManager;
import com.ufps.cuatro.util.render.MyListRendererJLabel;
import com.ufps.cuatro.util.wizard.UtilWizard;
import com.ufps.cuatro.vistas.JInternalFrameRepresentaciones;
import com.ufps.cuatro.vistas.asistente.espejo.complejo.wizard.JPanelWizardEspejoStandardSelectElements;

/**
 *<i><b>JDialogSeleccionPropiedadesClase:</b></i> @DefinicionClase
 * @author Carlos A. Torres C. - Dolly E. Guerrero. <https://code.google.com/p/tesis4dor/>
 * @version 1.0 2/03/2011
 * @see javax.swing.JDialog
 * @see ImplementarAyudaStandar
 * @see Observer
 */
public class JDialogSeleccionPropiedadesClase extends javax.swing.JDialog implements Observer, MessageWindow{
    private static final long serialVersionUID = 700455361838204943L;
    
    private Object objParent;
    private ObjetoTipoDatoReflexion objTipoDato;       
    private ArrayList<MyCheckItemPropertiesClass> objMetodos = null;
    private ArrayList<ObjetoTipoDatoReflexion> objTiposClase = null;    
    
    private boolean SETGET;        
    private String strClassPath;
    private CheckListManager checkListManager;
    
    public final static int DEFAULT_COLUMN_ADDED = 1;

    /** 
     * Creates new form JDialogSeleccionPropiedadesClase
     * @param parent @DefinicionParametro
     * @param modal  @DefinicionParametro
     */
    public JDialogSeleccionPropiedadesClase(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        this.setIconImage(Utileria.leerIconoAppEnImagen(Utileria.MODO_16x16).getImage());  
        this.objMetodos = new ArrayList<MyCheckItemPropertiesClass>();
    }

    /**
     * @DefinicionMetodo
     * @param objParent @DefinicionParametro
     */
    public JDialogSeleccionPropiedadesClase(Object objParent) {
        super(CuatroApp.getApplication().getMainFrame(), true);
        initComponents();
        this.objParent = objParent;
        this.setIconImage(Utileria.leerIconoAppEnImagen(Utileria.MODO_16x16).getImage());        
        this.objMetodos = new ArrayList<MyCheckItemPropertiesClass>();
        if(objParent instanceof ControllerListenerPopupJTree){
            SETGET = true;            
            ControllerListenerPopupJTree objTempParent = (ControllerListenerPopupJTree) objParent;
            this.objTipoDato = (ObjetoTipoDatoReflexion) objTempParent.getObjSeleccionado();
            this.jComboBoxClases.removeAllItems();
            this.jComboBoxClases.addItem(objTipoDato.getStrClassPath());
            this.jComboBoxClases.setSelectedIndex(0);            
            this.jComboBoxClases.setEnabled(false);                        
        }      
        else if(objParent instanceof JInternalFrameRepresentaciones){
            SETGET = true;            
            JInternalFrameRepresentaciones objTempParent = (JInternalFrameRepresentaciones) objParent;
            this.objTipoDato = objTempParent.getObjTipoDato();            
            this.jComboBoxClases.removeAllItems();
            this.jComboBoxClases.addItem(objTipoDato.getStrClassPath());
            this.jComboBoxClases.setSelectedIndex(0);            
            this.jComboBoxClases.setEnabled(false);                        
        }                 
    }
    
    /**
     * @DefinicionMetodo
     * @param objParent @DefinicionParametro
     */
    public JDialogSeleccionPropiedadesClase(JPanelWizardEspejoStandardSelectElements objParent) {
        super(UtilWizard.objWizard.getDialog(), true);
        initComponents();
        this.objParent = objParent;
        this.setIconImage(Utileria.leerIconoAppEnImagen(Utileria.MODO_16x16).getImage());        
        this.objMetodos = new ArrayList<MyCheckItemPropertiesClass>();        
        SETGET = false;            
        this.objTiposClase = UtilRepresentacion.getColeccionTipoDatoReflexion(TipoCaso.eClaseMundo);         
        this.jButtonUP.setEnabled(false);
        this.jButtonDOWN.setEnabled(false);
        this.jRadioButtonIn.setEnabled(false);
        this.jRadioButtonOut.setEnabled(false);        
        agregarWindowListener(objParent);
    }
    
    private void agregarWindowListener(final Object objParent) {
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowOpened(WindowEvent e) {
                super.windowOpened(e);
                if(objTiposClase.isEmpty()){
                    msgWarning("No existe Clases Analizadas.");                    
                    jComboBoxClases.setEnabled(false);            
                    Bandera objBandera = new Bandera();
                    objBandera.addObserver((Observer) objParent);
                    objBandera.setEstado(Bandera.PROCESO_CANCELADO);            
                    objBandera.notificar();
                    objBandera.setObj(null);
                    dispose();                 
                }
                else{
                    JComboBox objCombo = new JComboBox(objTiposClase.toArray());
                    jComboBoxClases.setModel(objCombo.getModel());                  
                    //this.jComboBoxClases.setSelectedIndex(0);
                }                 
            }
        });
    }
    
    private void loadRendererJListMethod() {
        JList objLista = new JList(objMetodos.toArray());
        this.jListMetodos.setModel(objLista.getModel());
        this.jListMetodos.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        
        MyListRendererJLabel objRender = new MyListRendererJLabel(0);
        this.jListMetodos.setCellRenderer(objRender);
        checkListManager = new CheckListManager(jListMetodos);                 
    }
    
    private boolean cargarPropiedades(){
        try{
            Class<?> objClass = null;
            strClassPath = this.objTipoDato.getStrClassPath();
            //Se comprueba que objeto la clase este registrada
            if(this.objTipoDato.getObjClass() != null){
                objClass = this.objTipoDato.getObjClass();
            }
            else{                
                objClass = Class.forName(strClassPath);
            }
            //se extraen las propiedades;            
            Method[] objTempMetodos = objClass.getMethods();  
            List<Method> ListMethods = Arrays.asList(objTempMetodos);
            this.objMetodos     = new ArrayList<MyCheckItemPropertiesClass>();                 
            
            for(Method objMethod : ListMethods){
                if(SETGET){
                    if((UtilRepresentacion.isGetter(objMethod) || UtilRepresentacion.isIs(objMethod)) && !UtilRepresentacion.isMetodoExcluido(objMethod)){
                        MyCheckItemPropertiesClass objItem = new MyCheckItemPropertiesClass(objMethod);
                        if(objTipoDato.getObjCaso().geteCaso() == TipoCaso.eJDKNoRegistrado){
                            Class<?> objClassTipoDato = objMethod.getReturnType();
                            if(UtilRepresentacion.isExisteTipoDato(objClassTipoDato)){
                                this.objMetodos.add(objItem);
                            }
                        }
                        else{
                            this.objMetodos.add(objItem);
                        }
                    }
                    else if(UtilRepresentacion.isSetter(objMethod) && !UtilRepresentacion.isMetodoExcluido(objMethod)){
                        MyCheckItemPropertiesClass objItem = new MyCheckItemPropertiesClass(objMethod);
                        if(objTipoDato.getObjCaso().geteCaso() == TipoCaso.eJDKNoRegistrado){
                            Class<?> objClassTipoDato = objMethod.getParameterTypes()[0];
                            if(UtilRepresentacion.isExisteTipoDato(objClassTipoDato)){
                                this.objMetodos.add(objItem);
                            }
                        }
                        else{
                            this.objMetodos.add(objItem);
                        }
                    }
                }
                else{
                    if(!UtilRepresentacion.isGetter(objMethod) && 
                            !UtilRepresentacion.isIs(objMethod) && 
                            !UtilRepresentacion.isSetter(objMethod) &&
                            !UtilRepresentacion.isMetodoExcluido(objMethod)){
                        MyCheckItemPropertiesClass objItem = new MyCheckItemPropertiesClass(objMethod);
                        if(objTipoDato.getObjCaso().geteCaso() == TipoCaso.eJDKNoRegistrado){
                            Class<?> objClassTipoDato = objMethod.getReturnType();
                            if(UtilRepresentacion.isExisteTipoDato(objClassTipoDato)){
                                this.objMetodos.add(objItem);
                            }
                        }
                        else{
                            this.objMetodos.add(objItem);
                        }
                    }                                        
                }
            }
            
            if(this.objMetodos.isEmpty())return false;          
            
            loadRendererJListMethod();
            return true;
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(JDialogSeleccionPropiedadesClase.class.getName()).log(Level.SEVERE, null, ex);
        }catch(java.lang.NullPointerException ex){            
            Logger.getLogger(JDialogSeleccionPropiedadesClase.class.getName()).log(Level.SEVERE, null, ex);
        }catch(java.lang.IndexOutOfBoundsException ex){            
            Logger.getLogger(JDialogSeleccionPropiedadesClase.class.getName()).log(Level.SEVERE, null, ex);
        }catch(java.lang.ArrayStoreException ex){            
            Logger.getLogger(JDialogSeleccionPropiedadesClase.class.getName()).log(Level.SEVERE, null, ex);
        }
        return false;
    }

    private void reiniciarCargarPropiedadesClase() {
        this.objMetodos.clear();
        this.loadRendererJListMethod();
    }
    
    private void seleccionarMetodos(int modo, boolean estado){
        switch(modo){
            case Utileria.GET://get
                for(MyCheckItemPropertiesClass objItem : this.objMetodos){
                    Method objMetodo = objItem.getObjMethod();
                    if(UtilRepresentacion.isGetter(objMetodo) || UtilRepresentacion.isIs(objMetodo)){
                        objItem.setSelected(estado);
                    }                
                }
                break;
            case Utileria.SET://set
                for(MyCheckItemPropertiesClass objItem : this.objMetodos){
                    Method objMetodo = objItem.getObjMethod();
                    if(UtilRepresentacion.isSetter(objMetodo)){
                        objItem.setSelected(estado);
                    }
                }
                break;
            case Utileria.CLS://borrar
                for(MyCheckItemPropertiesClass objItem : this.objMetodos){                    
                    objItem.setSelected(estado);                    
                }
                break;
        }
        loadRendererJListMethod();        
    }          

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jToolBar1 = new javax.swing.JToolBar();
        jButton1 = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JToolBar.Separator();
        jButton2 = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JToolBar.Separator();
        jButton3 = new javax.swing.JButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jListMetodos = new javax.swing.JList();
        jButtonUP = new javax.swing.JButton();
        jButtonDOWN = new javax.swing.JButton();
        jRadioButtonOut = new javax.swing.JRadioButton();
        jRadioButtonIn = new javax.swing.JRadioButton();
        jLabel1 = new javax.swing.JLabel();
        jComboBoxClases = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance().getContext().getResourceMap(JDialogSeleccionPropiedadesClase.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N
        setResizable(false);

        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);
        jToolBar1.setName("jToolBar1"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance().getContext().getActionMap(JDialogSeleccionPropiedadesClase.class, this);
        jButton1.setAction(actionMap.get("aceptar")); // NOI18N
        jButton1.setFocusable(false);
        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton1.setName("jButton1"); // NOI18N
        jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(jButton1);

        jSeparator3.setName("jSeparator3"); // NOI18N
        jToolBar1.add(jSeparator3);

        jButton2.setAction(actionMap.get("cancelar")); // NOI18N
        jButton2.setFocusable(false);
        jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton2.setName("jButton2"); // NOI18N
        jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(jButton2);

        jSeparator2.setName("jSeparator2"); // NOI18N
        jToolBar1.add(jSeparator2);

        jButton3.setAction(actionMap.get("infoHelp")); // NOI18N
        jButton3.setFocusable(false);
        jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton3.setName("jButton3"); // NOI18N
        jButton3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(jButton3);

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        jPanel1.setName("jPanel1"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jListMetodos.setName("jListMetodos"); // NOI18N
        jListMetodos.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jListMetodosMouseClicked(evt);
            }
        });
        jListMetodos.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jListMetodosValueChanged(evt);
            }
        });
        jScrollPane2.setViewportView(jListMetodos);

        jButtonUP.setAction(actionMap.get("up")); // NOI18N
        jButtonUP.setName("jButtonUP"); // NOI18N

        jButtonDOWN.setAction(actionMap.get("down")); // NOI18N
        jButtonDOWN.setName("jButtonDOWN"); // NOI18N

        buttonGroup2.add(jRadioButtonOut);
        jRadioButtonOut.setText(resourceMap.getString("jRadioButtonOut.text")); // NOI18N
        jRadioButtonOut.setName("jRadioButtonOut"); // NOI18N

        buttonGroup2.add(jRadioButtonIn);
        jRadioButtonIn.setSelected(true);
        jRadioButtonIn.setText(resourceMap.getString("jRadioButtonIn.text")); // NOI18N
        jRadioButtonIn.setName("jRadioButtonIn"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jRadioButtonOut, javax.swing.GroupLayout.DEFAULT_SIZE, 364, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 264, Short.MAX_VALUE)
                                .addGap(6, 6, 6)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel1)
                                    .addComponent(jButtonDOWN, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jButtonUP, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jRadioButtonIn, javax.swing.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE)
                        .addGap(14, 14, 14))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonUP)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonDOWN))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jRadioButtonIn)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jRadioButtonOut)
                .addContainerGap())
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel1.TabConstraints.tabTitle"), jPanel1); // NOI18N

        jComboBoxClases.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Seleccione una Clase" }));
        jComboBoxClases.setAction(actionMap.get("seleccionClase")); // NOI18N
        jComboBoxClases.setName("jComboBoxClases"); // NOI18N

        jLabel2.setBackground(resourceMap.getColor("jLabel2.background")); // NOI18N
        jLabel2.setIcon(resourceMap.getIcon("jLabel2.icon")); // NOI18N
        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jLabel2.setName("jLabel2"); // NOI18N
        jLabel2.setOpaque(true);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 389, Short.MAX_VALUE)
                    .addComponent(jComboBoxClases, javax.swing.GroupLayout.Alignment.LEADING, 0, 389, Short.MAX_VALUE)
                    .addComponent(jToolBar1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 389, Short.MAX_VALUE))
                .addContainerGap())
            .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 409, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBoxClases, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 535, Short.MAX_VALUE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jListMetodosValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListMetodosValueChanged
        int i = 0;
        if(!this.objMetodos.isEmpty()){
            for(MyCheckItemPropertiesClass objItem : this.objMetodos){
                if(objItem.isSelected()){
                    i++;
                }
            }
        }        
    }//GEN-LAST:event_jListMetodosValueChanged

    private void jListMetodosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jListMetodosMouseClicked
        
    }//GEN-LAST:event_jListMetodosMouseClicked

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                JDialogSeleccionPropiedadesClase dialog = new JDialogSeleccionPropiedadesClase(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    /**
     * @DefinicionMmetodo
     */
    @Action
    public void aceptar() {        
        ArrayList<ObjetoReflexion> objPropiedades = new ArrayList<ObjetoReflexion>();
        //se agregan los Inluidos en Propiedades        
        if(this.objMetodos.isEmpty()){
            msgWarning("No existen Métodos.");                        
            return;
        }        
        if(!this.objMetodos.isEmpty()){
            for(MyCheckItemPropertiesClass objItem : this.objMetodos){
                if(objItem.isSelected()){
                    ObjetoReflexion objMethod = new ObjetoReflexion(objItem.getObjMethod());
                    objPropiedades.add(objMethod);                    
                }
            }
        }
        if(objPropiedades.isEmpty()){
            msgWarning("No existen Métodos Seleccionados.");                                                
            return;
        }
        
        String strMsg = java.util.ResourceBundle.getBundle("com/ufps/cuatro/vistas/representacion/resources/JDialogSeleccionPropiedadesClase").getString("¿DESEAS REPRESENTAR LA PRPOIEDADES Y MÉTODOS SELECIONADOS?");
        if(msgConfirm(strMsg)){
            Bandera objBandera = new Bandera();
            objBandera.addObserver((Observer) objParent);
            objBandera.setEstado(Bandera.SELECCION_PROPIEDADES_CLASE_REPRESENTACION);            
            objBandera.setObj(objPropiedades);
            objBandera.add(Bandera.OPC_OBJECT_INCLUIDO, objTipoDato);
            if(SETGET){
                if(this.jRadioButtonOut.isSelected()){
                    objBandera.setInt(Utileria.GET);
                }
                else if(this.jRadioButtonIn.isSelected()){
                    objBandera.setInt(Utileria.SET);
                }
            }
            else{
                objBandera.setInt(Utileria.ALL);
            }
            objBandera.notificar();
            dispose();
        }
    }

    /**
     * @DefinicionMetodo
     */
    @Action
    public void cancelar() {
        String strMsg = Utileria.leerRecursoTexto("Utileria.msg.salir.window");        
        if(msgConfirm(strMsg)){
            Bandera objBandera = new Bandera();
            objBandera.addObserver((Observer) objParent);
            objBandera.setEstado(Bandera.PROCESO_CANCELADO);            
            objBandera.notificar();
            objBandera.setObj(null);
            dispose();
        }
    }

    /**
     * Permite cargarArchivoMyPropierties la ventana de ayuda.
     */
    @Action
    public void infoHelp() {
        UtilRender.openDialogHelp(JDialogSeleccionPropiedadesClase.class, getTitle());
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButtonDOWN;
    private javax.swing.JButton jButtonUP;
    private javax.swing.JComboBox jComboBoxClases;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JList jListMetodos;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JRadioButton jRadioButtonIn;
    private javax.swing.JRadioButton jRadioButtonOut;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JToolBar.Separator jSeparator2;
    private javax.swing.JToolBar.Separator jSeparator3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JToolBar jToolBar1;
    // End of variables declaration//GEN-END:variables

    public void update(Observable o, Object arg) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Action
    public void seleccionClase() {        
        if(this.jComboBoxClases.getSelectedIndex() > -1){
//            if(existeSeleccionListaMetodos() || existeSeleccionListaAtributos()){
//                if(!Utileria.confirmarOrden(CuatroApp.getApplication().getMainFrame(), 
//                        "Existe una Selección Previa, si carga otra Clase se perderá la Configuración.\n" 
//                        + "¿Desea Continuar?", "")){
//                    return;
//                }
//            }
            if(this.jComboBoxClases.getSelectedItem() instanceof String){
                strClassPath = (String) this.jComboBoxClases.getSelectedItem();            
                if(!this.cargarPropiedades()){                    
                    msgWarning("La Clase: " + strClassPath + " no Contiene Métodos para Representar."); 
                    reiniciarCargarPropiedadesClase();
                }
            }
            else if(this.jComboBoxClases.getSelectedItem() instanceof ObjetoTipoDatoReflexion){
                objTipoDato = (ObjetoTipoDatoReflexion) this.jComboBoxClases.getSelectedItem();            
                strClassPath = objTipoDato.getStrClassPath();
                if(!this.cargarPropiedades()){                    
                    msgWarning("La Clase: " + strClassPath + " no Contiene Métodos para Representar.");                    
                    reiniciarCargarPropiedadesClase();
                }
            }                            
        }
    }

    @Action
    public void ordenarColeccion() {        
    }

    @Action
    public void up() {
        if(this.jListMetodos.isSelectionEmpty()){
            msgWarning("Debe Seleccionar un Método.");
            return;
        }
        if(this.jListMetodos.getSelectedIndex() <= 0)return;
        int i = this.jListMetodos.getSelectedIndex();
        MyCheckItemPropertiesClass objItemActual = (MyCheckItemPropertiesClass) this.objMetodos.get(i).clone();
        MyCheckItemPropertiesClass objItemTemp = (MyCheckItemPropertiesClass) this.objMetodos.get(i - 1).clone();        
        this.objMetodos.set(i - 1, objItemActual);
        this.objMetodos.set(i    , objItemTemp);
        loadRendererJListMethod();
        this.jListMetodos.setSelectedIndex(i - 1);

    }

    @Action
    public void down() {
        if(this.jListMetodos.isSelectionEmpty()){
            msgWarning("Debe Seleccionar un Método.");
            return;
        }
        if(this.jListMetodos.getSelectedIndex() >= this.objMetodos.size() - 1)return;
        int i = this.jListMetodos.getSelectedIndex();
        MyCheckItemPropertiesClass objItemActual = (MyCheckItemPropertiesClass) this.objMetodos.get(i).clone();
        MyCheckItemPropertiesClass objItemTemp = (MyCheckItemPropertiesClass) this.objMetodos.get(i + 1).clone();        
        this.objMetodos.set(i + 1, objItemActual);
        this.objMetodos.set(i    , objItemTemp);
        loadRendererJListMethod();
        this.jListMetodos.setSelectedIndex(i + 1); 
    }

    @Action
    public void upField() {        
    }

    @Action
    public void downField() {        
    }

    private boolean existeSeleccionListaMetodos(){        
        for(int i = 0; i < this.objMetodos.size(); i++){
            if(this.jListMetodos.getSelectionModel().isSelectedIndex(i))
                return true;
        }
        return false;
    }

    public boolean msgConfirm(String strMsg) {
        if(objParent instanceof JPanelWizardEspejoStandardSelectElements){
            return UtilRender.msgConfirmar(strMsg, UtilWizard.objWizard.getDialog());
        }
        else{
            return UtilRender.msgConfirmar(strMsg);
        }
    }

    public void msgInfo(String strMsg) {
        if(objParent instanceof JPanelWizardEspejoStandardSelectElements){
            UtilRender.msgInformacion(strMsg, UtilWizard.objWizard.getDialog());
        }
        else{
            UtilRender.msgInformacion(strMsg);
        }
    }

    public void msgWarning(String strMsg) {
        if(objParent instanceof JPanelWizardEspejoStandardSelectElements){
            UtilRender.msgAdvertencia(strMsg, UtilWizard.objWizard.getDialog());
        }
        else{
            UtilRender.msgAdvertencia(strMsg);
        }
    }

    public void msgError(String strMsg) {
        if(objParent instanceof JPanelWizardEspejoStandardSelectElements){
            UtilRender.msgError(strMsg, UtilWizard.objWizard.getDialog());
        }
        else{
            UtilRender.msgError(strMsg);
        }
    }
}
